<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>GSocketConnectable: GIO Reference Manual</title>
<meta name="generator" content="DocBook XSL Stylesheets Vsnapshot">
<link rel="home" href="index.html" title="GIO Reference Manual">
<link rel="up" href="resolver.html" title="DNS resolution">
<link rel="prev" href="GSimpleProxyResolver.html" title="GSimpleProxyResolver">
<link rel="next" href="GSocketAddressEnumerator.html" title="GSocketAddressEnumerator">
<meta name="generator" content="GTK-Doc V1.26.1 (XML mode)">
<link rel="stylesheet" href="style.css" type="text/css">
</head>
<body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF">
<table class="navigation" id="top" width="100%" summary="Navigation header" cellpadding="2" cellspacing="5"><tr valign="middle">
<td width="100%" align="left" class="shortcuts">
<a href="#" class="shortcut">Top</a><span id="nav_description">  <span class="dim">|</span> 
                  <a href="#GSocketConnectable.description" class="shortcut">Description</a></span><span id="nav_hierarchy">  <span class="dim">|</span> 
                  <a href="#GSocketConnectable.object-hierarchy" class="shortcut">Object Hierarchy</a></span><span id="nav_prerequisites">  <span class="dim">|</span> 
                  <a href="#GSocketConnectable.prerequisites" class="shortcut">Prerequisites</a></span><span id="nav_implementations">  <span class="dim">|</span> 
                  <a href="#GSocketConnectable.implementations" class="shortcut">Known Implementations</a></span>
</td>
<td><a accesskey="h" href="index.html"><img src="home.png" width="16" height="16" border="0" alt="Home"></a></td>
<td><a accesskey="u" href="resolver.html"><img src="up.png" width="16" height="16" border="0" alt="Up"></a></td>
<td><a accesskey="p" href="GSimpleProxyResolver.html"><img src="left.png" width="16" height="16" border="0" alt="Prev"></a></td>
<td><a accesskey="n" href="GSocketAddressEnumerator.html"><img src="right.png" width="16" height="16" border="0" alt="Next"></a></td>
</tr></table>
<div class="refentry">
<a name="GSocketConnectable"></a><div class="titlepage"></div>
<div class="refnamediv"><table width="100%"><tr>
<td valign="top">
<h2><span class="refentrytitle"><a name="GSocketConnectable.top_of_page"></a>GSocketConnectable</span></h2>
<p>GSocketConnectable — Interface for potential socket endpoints</p>
</td>
<td class="gallery_image" valign="top" align="right"></td>
</tr></table></div>
<div class="refsect1">
<a name="GSocketConnectable.functions"></a><h2>Functions</h2>
<div class="informaltable"><table class="informaltable" width="100%" border="0">
<colgroup>
<col width="150px" class="functions_return">
<col class="functions_name">
</colgroup>
<tbody>
<tr>
<td class="function_type">
<a class="link" href="GSocketAddressEnumerator.html" title="GSocketAddressEnumerator"><span class="returnvalue">GSocketAddressEnumerator</span></a> *
</td>
<td class="function_name">
<a class="link" href="GSocketConnectable.html#g-socket-connectable-enumerate" title="g_socket_connectable_enumerate ()">g_socket_connectable_enumerate</a> <span class="c_punctuation">()</span>
</td>
</tr>
<tr>
<td class="function_type">
<a class="link" href="GSocketAddressEnumerator.html" title="GSocketAddressEnumerator"><span class="returnvalue">GSocketAddressEnumerator</span></a> *
</td>
<td class="function_name">
<a class="link" href="GSocketConnectable.html#g-socket-connectable-proxy-enumerate" title="g_socket_connectable_proxy_enumerate ()">g_socket_connectable_proxy_enumerate</a> <span class="c_punctuation">()</span>
</td>
</tr>
<tr>
<td class="function_type">
<a href="../glib-Basic-Types.html#gchar"><span class="returnvalue">gchar</span></a> *
</td>
<td class="function_name">
<a class="link" href="GSocketConnectable.html#g-socket-connectable-to-string" title="g_socket_connectable_to_string ()">g_socket_connectable_to_string</a> <span class="c_punctuation">()</span>
</td>
</tr>
</tbody>
</table></div>
</div>
<div class="refsect1">
<a name="GSocketConnectable.other"></a><h2>Types and Values</h2>
<div class="informaltable"><table class="informaltable" width="100%" border="0">
<colgroup>
<col width="150px" class="name">
<col class="description">
</colgroup>
<tbody>
<tr>
<td class="datatype_keyword"> </td>
<td class="function_name"><a class="link" href="GSocketConnectable.html#GSocketConnectable-struct" title="GSocketConnectable">GSocketConnectable</a></td>
</tr>
<tr>
<td class="datatype_keyword">struct</td>
<td class="function_name"><a class="link" href="GSocketConnectable.html#GSocketConnectableIface" title="struct GSocketConnectableIface">GSocketConnectableIface</a></td>
</tr>
</tbody>
</table></div>
</div>
<div class="refsect1">
<a name="GSocketConnectable.object-hierarchy"></a><h2>Object Hierarchy</h2>
<pre class="screen">    <a href="/home/mclasen/gnome/share/gtk-doc/html/gobject/GTypeModule.html">GInterface</a>
    <span class="lineart">╰──</span> GSocketConnectable
</pre>
</div>
<div class="refsect1">
<a name="GSocketConnectable.prerequisites"></a><h2>Prerequisites</h2>
<p>
GSocketConnectable requires
 <a href="../gobject-The-Base-Object-Type.html#GObject-struct">GObject</a>.</p>
</div>
<div class="refsect1">
<a name="GSocketConnectable.implementations"></a><h2>Known Implementations</h2>
<p>
GSocketConnectable is implemented by
 <a class="link" href="GInetSocketAddress.html" title="GInetSocketAddress">GInetSocketAddress</a>,  <a class="link" href="GNetworkAddress.html" title="GNetworkAddress">GNetworkAddress</a>,  <a class="link" href="GNetworkService.html" title="GNetworkService">GNetworkService</a>,  <a class="link" href="GProxyAddress.html" title="GProxyAddress">GProxyAddress</a>,  <a class="link" href="GSocketAddress.html" title="GSocketAddress">GSocketAddress</a> and  <a class="link" href="GUnixSocketAddress.html" title="GUnixSocketAddress">GUnixSocketAddress</a>.</p>
</div>
<div class="refsect1">
<a name="GSocketConnectable.includes"></a><h2>Includes</h2>
<pre class="synopsis">#include &lt;gio/gio.h&gt;
</pre>
</div>
<div class="refsect1">
<a name="GSocketConnectable.description"></a><h2>Description</h2>
<p>Objects that describe one or more potential socket endpoints
implement <a class="link" href="GSocketConnectable.html" title="GSocketConnectable"><span class="type">GSocketConnectable</span></a>. Callers can then use
<a class="link" href="GSocketConnectable.html#g-socket-connectable-enumerate" title="g_socket_connectable_enumerate ()"><code class="function">g_socket_connectable_enumerate()</code></a> to get a <a class="link" href="GSocketAddressEnumerator.html" title="GSocketAddressEnumerator"><span class="type">GSocketAddressEnumerator</span></a>
to try out each socket address in turn until one succeeds, as shown
in the sample code below.</p>
<div class="informalexample">
  <table class="listing_frame" border="0" cellpadding="0" cellspacing="0">
    <tbody>
      <tr>
        <td class="listing_lines" align="right"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49</pre></td>
        <td class="listing_code"><pre class="programlisting">MyConnectionType <span class="gtkdoc opt">*</span>
<span class="function">connect_to_host</span> <span class="gtkdoc opt">(</span><span class="gtkdoc kwb">const char</span>    <span class="gtkdoc opt">*</span>hostname<span class="gtkdoc opt">,</span>
                 guint16        port<span class="gtkdoc opt">,</span>
                 GCancellable  <span class="gtkdoc opt">*</span>cancellable<span class="gtkdoc opt">,</span>
                 GError       <span class="gtkdoc opt">**</span>error<span class="gtkdoc opt">)</span>
<span class="gtkdoc opt">{</span>
  MyConnection <span class="gtkdoc opt">*</span>conn <span class="gtkdoc opt">=</span> NULL<span class="gtkdoc opt">;</span>
  GSocketConnectable <span class="gtkdoc opt">*</span>addr<span class="gtkdoc opt">;</span>
  GSocketAddressEnumerator <span class="gtkdoc opt">*</span>enumerator<span class="gtkdoc opt">;</span>
  GSocketAddress <span class="gtkdoc opt">*</span>sockaddr<span class="gtkdoc opt">;</span>
  GError <span class="gtkdoc opt">*</span>conn_error <span class="gtkdoc opt">=</span> NULL<span class="gtkdoc opt">;</span>

  addr <span class="gtkdoc opt">=</span> <span class="function"><a href="GNetworkAddress.html#g-network-address-new">g_network_address_new</a></span> <span class="gtkdoc opt">(</span>hostname<span class="gtkdoc opt">,</span> port<span class="gtkdoc opt">);</span>
  enumerator <span class="gtkdoc opt">=</span> <span class="function"><a href="GSocketConnectable.html#g-socket-connectable-enumerate">g_socket_connectable_enumerate</a></span> <span class="gtkdoc opt">(</span>addr<span class="gtkdoc opt">);</span>
  <span class="function"><a href="../gobject-The-Base-Object-Type.html#g-object-unref">g_object_unref</a></span> <span class="gtkdoc opt">(</span>addr<span class="gtkdoc opt">);</span>

  <span class="gtkdoc slc">// Try each sockaddr until we succeed. Record the first connection error,</span>
  <span class="gtkdoc slc">// but not any further ones (since they&apos;ll probably be basically the same</span>
  <span class="gtkdoc slc">// as the first).</span>
  <span class="keyword">while</span> <span class="gtkdoc opt">(!</span>conn <span class="gtkdoc opt">&amp;&amp; (</span>sockaddr <span class="gtkdoc opt">=</span> <span class="function"><a href="GSocketAddressEnumerator.html#g-socket-address-enumerator-next">g_socket_address_enumerator_next</a></span> <span class="gtkdoc opt">(</span>enumerator<span class="gtkdoc opt">,</span> cancellable<span class="gtkdoc opt">,</span> error<span class="gtkdoc opt">))</span>
    <span class="gtkdoc opt">{</span>
      conn <span class="gtkdoc opt">=</span> <span class="function">connect_to_sockaddr</span> <span class="gtkdoc opt">(</span>sockaddr<span class="gtkdoc opt">,</span> conn_error <span class="gtkdoc opt">?</span> NULL <span class="gtkdoc opt">: &amp;</span>conn_error<span class="gtkdoc opt">);</span>
      <span class="function"><a href="../gobject-The-Base-Object-Type.html#g-object-unref">g_object_unref</a></span> <span class="gtkdoc opt">(</span>sockaddr<span class="gtkdoc opt">);</span>
    <span class="gtkdoc opt">}</span>
  <span class="function"><a href="../gobject-The-Base-Object-Type.html#g-object-unref">g_object_unref</a></span> <span class="gtkdoc opt">(</span>enumerator<span class="gtkdoc opt">);</span>

  <span class="keyword">if</span> <span class="gtkdoc opt">(</span>conn<span class="gtkdoc opt">)</span>
    <span class="gtkdoc opt">{</span>
      <span class="keyword">if</span> <span class="gtkdoc opt">(</span>conn_error<span class="gtkdoc opt">)</span>
        <span class="gtkdoc opt">{</span>
          <span class="gtkdoc slc">// We couldn&apos;t connect to the first address, but we succeeded</span>
          <span class="gtkdoc slc">// in connecting to a later address.</span>
          <span class="function"><a href="../glib-Error-Reporting.html#g-error-free">g_error_free</a></span> <span class="gtkdoc opt">(</span>conn_error<span class="gtkdoc opt">);</span>
        <span class="gtkdoc opt">}</span>
      <span class="keyword">return</span> conn<span class="gtkdoc opt">;</span>
    <span class="gtkdoc opt">}</span>
  <span class="keyword">else if</span> <span class="gtkdoc opt">(</span>error<span class="gtkdoc opt">)</span>
    <span class="gtkdoc opt">{</span>
      <span class="gtkdoc slc">/// Either initial lookup failed, or else the caller cancelled us.</span>
      <span class="keyword">if</span> <span class="gtkdoc opt">(</span>conn_error<span class="gtkdoc opt">)</span>
        <span class="function"><a href="../glib-Error-Reporting.html#g-error-free">g_error_free</a></span> <span class="gtkdoc opt">(</span>conn_error<span class="gtkdoc opt">);</span>
      <span class="keyword">return</span> NULL<span class="gtkdoc opt">;</span>
    <span class="gtkdoc opt">}</span>
  <span class="keyword">else</span>
    <span class="gtkdoc opt">{</span>
      <span class="function">g_error_propagate</span> <span class="gtkdoc opt">(</span>error<span class="gtkdoc opt">,</span> conn_error<span class="gtkdoc opt">);</span>
      <span class="keyword">return</span> NULL<span class="gtkdoc opt">;</span>
    <span class="gtkdoc opt">}</span>
<span class="gtkdoc opt">}</span></pre></td>
      </tr>
    </tbody>
  </table>
</div>

<p></p>
</div>
<div class="refsect1">
<a name="GSocketConnectable.functions_details"></a><h2>Functions</h2>
<div class="refsect2">
<a name="g-socket-connectable-enumerate"></a><h3>g_socket_connectable_enumerate ()</h3>
<pre class="programlisting"><a class="link" href="GSocketAddressEnumerator.html" title="GSocketAddressEnumerator"><span class="returnvalue">GSocketAddressEnumerator</span></a> *
g_socket_connectable_enumerate (<em class="parameter"><code><a class="link" href="GSocketConnectable.html" title="GSocketConnectable"><span class="type">GSocketConnectable</span></a> *connectable</code></em>);</pre>
<p>Creates a <a class="link" href="GSocketAddressEnumerator.html" title="GSocketAddressEnumerator"><span class="type">GSocketAddressEnumerator</span></a> for <em class="parameter"><code>connectable</code></em>
.</p>
<div class="refsect3">
<a name="g-socket-connectable-enumerate.parameters"></a><h4>Parameters</h4>
<div class="informaltable"><table class="informaltable" width="100%" border="0">
<colgroup>
<col width="150px" class="parameters_name">
<col class="parameters_description">
<col width="200px" class="parameters_annotations">
</colgroup>
<tbody><tr>
<td class="parameter_name"><p>connectable</p></td>
<td class="parameter_description"><p>a <a class="link" href="GSocketConnectable.html" title="GSocketConnectable"><span class="type">GSocketConnectable</span></a></p></td>
<td class="parameter_annotations"> </td>
</tr></tbody>
</table></div>
</div>
<div class="refsect3">
<a name="g-socket-connectable-enumerate.returns"></a><h4>Returns</h4>
<p>a new <a class="link" href="GSocketAddressEnumerator.html" title="GSocketAddressEnumerator"><span class="type">GSocketAddressEnumerator</span></a>. </p>
<p><span class="annotation">[<acronym title="Free data after the code is done."><span class="acronym">transfer full</span></acronym>]</span></p>
</div>
<p class="since">Since: <a class="link" href="api-index-2-22.html#api-index-2.22">2.22</a></p>
</div>
<hr>
<div class="refsect2">
<a name="g-socket-connectable-proxy-enumerate"></a><h3>g_socket_connectable_proxy_enumerate ()</h3>
<pre class="programlisting"><a class="link" href="GSocketAddressEnumerator.html" title="GSocketAddressEnumerator"><span class="returnvalue">GSocketAddressEnumerator</span></a> *
g_socket_connectable_proxy_enumerate (<em class="parameter"><code><a class="link" href="GSocketConnectable.html" title="GSocketConnectable"><span class="type">GSocketConnectable</span></a> *connectable</code></em>);</pre>
<p>Creates a <a class="link" href="GSocketAddressEnumerator.html" title="GSocketAddressEnumerator"><span class="type">GSocketAddressEnumerator</span></a> for <em class="parameter"><code>connectable</code></em>
 that will
return <span class="type">GProxyAddresses</span> for addresses that you must connect
to via a proxy.</p>
<p>If <em class="parameter"><code>connectable</code></em>
 does not implement
<a class="link" href="GSocketConnectable.html#g-socket-connectable-proxy-enumerate" title="g_socket_connectable_proxy_enumerate ()"><code class="function">g_socket_connectable_proxy_enumerate()</code></a>, this will fall back to
calling <a class="link" href="GSocketConnectable.html#g-socket-connectable-enumerate" title="g_socket_connectable_enumerate ()"><code class="function">g_socket_connectable_enumerate()</code></a>.</p>
<div class="refsect3">
<a name="g-socket-connectable-proxy-enumerate.parameters"></a><h4>Parameters</h4>
<div class="informaltable"><table class="informaltable" width="100%" border="0">
<colgroup>
<col width="150px" class="parameters_name">
<col class="parameters_description">
<col width="200px" class="parameters_annotations">
</colgroup>
<tbody><tr>
<td class="parameter_name"><p>connectable</p></td>
<td class="parameter_description"><p>a <a class="link" href="GSocketConnectable.html" title="GSocketConnectable"><span class="type">GSocketConnectable</span></a></p></td>
<td class="parameter_annotations"> </td>
</tr></tbody>
</table></div>
</div>
<div class="refsect3">
<a name="g-socket-connectable-proxy-enumerate.returns"></a><h4>Returns</h4>
<p>a new <a class="link" href="GSocketAddressEnumerator.html" title="GSocketAddressEnumerator"><span class="type">GSocketAddressEnumerator</span></a>. </p>
<p><span class="annotation">[<acronym title="Free data after the code is done."><span class="acronym">transfer full</span></acronym>]</span></p>
</div>
<p class="since">Since: <a class="link" href="api-index-2-26.html#api-index-2.26">2.26</a></p>
</div>
<hr>
<div class="refsect2">
<a name="g-socket-connectable-to-string"></a><h3>g_socket_connectable_to_string ()</h3>
<pre class="programlisting"><a href="../glib-Basic-Types.html#gchar"><span class="returnvalue">gchar</span></a> *
g_socket_connectable_to_string (<em class="parameter"><code><a class="link" href="GSocketConnectable.html" title="GSocketConnectable"><span class="type">GSocketConnectable</span></a> *connectable</code></em>);</pre>
<p>Format a <a class="link" href="GSocketConnectable.html" title="GSocketConnectable"><span class="type">GSocketConnectable</span></a> as a string. This is a human-readable format for
use in debugging output, and is not a stable serialization format. It is not
suitable for use in user interfaces as it exposes too much information for a
user.</p>
<p>If the <a class="link" href="GSocketConnectable.html" title="GSocketConnectable"><span class="type">GSocketConnectable</span></a> implementation does not support string formatting,
the implementation’s type name will be returned as a fallback.</p>
<div class="refsect3">
<a name="g-socket-connectable-to-string.parameters"></a><h4>Parameters</h4>
<div class="informaltable"><table class="informaltable" width="100%" border="0">
<colgroup>
<col width="150px" class="parameters_name">
<col class="parameters_description">
<col width="200px" class="parameters_annotations">
</colgroup>
<tbody><tr>
<td class="parameter_name"><p>connectable</p></td>
<td class="parameter_description"><p>a <a class="link" href="GSocketConnectable.html" title="GSocketConnectable"><span class="type">GSocketConnectable</span></a></p></td>
<td class="parameter_annotations"> </td>
</tr></tbody>
</table></div>
</div>
<div class="refsect3">
<a name="g-socket-connectable-to-string.returns"></a><h4>Returns</h4>
<p>the formatted string. </p>
<p><span class="annotation">[<acronym title="Free data after the code is done."><span class="acronym">transfer full</span></acronym>]</span></p>
</div>
<p class="since">Since: <a class="link" href="api-index-2-48.html#api-index-2.48">2.48</a></p>
</div>
</div>
<div class="refsect1">
<a name="GSocketConnectable.other_details"></a><h2>Types and Values</h2>
<div class="refsect2">
<a name="GSocketConnectable-struct"></a><h3>GSocketConnectable</h3>
<pre class="programlisting">typedef struct _GSocketConnectable GSocketConnectable;</pre>
<p>Interface for objects that contain or generate <a class="link" href="GSocketAddress.html" title="GSocketAddress"><span class="type">GSocketAddress</span></a>&lt;!-- --&gt;es.</p>
</div>
<hr>
<div class="refsect2">
<a name="GSocketConnectableIface"></a><h3>struct GSocketConnectableIface</h3>
<pre class="programlisting">struct GSocketConnectableIface {
  GTypeInterface g_iface;

  /* Virtual Table */

  GSocketAddressEnumerator * (* enumerate)       (GSocketConnectable *connectable);

  GSocketAddressEnumerator * (* proxy_enumerate) (GSocketConnectable *connectable);

  gchar                    * (* to_string)       (GSocketConnectable *connectable);
};
</pre>
<p>Provides an interface for returning a <a class="link" href="GSocketAddressEnumerator.html" title="GSocketAddressEnumerator"><span class="type">GSocketAddressEnumerator</span></a>
and <a class="link" href="GProxyAddressEnumerator.html" title="GProxyAddressEnumerator"><span class="type">GProxyAddressEnumerator</span></a></p>
<div class="refsect3">
<a name="GSocketConnectableIface.members"></a><h4>Members</h4>
<div class="informaltable"><table class="informaltable" width="100%" border="0">
<colgroup>
<col width="300px" class="struct_members_name">
<col class="struct_members_description">
<col width="200px" class="struct_members_annotations">
</colgroup>
<tbody>
<tr>
<td class="struct_member_name"><p><em class="structfield"><code><a name="GSocketConnectableIface.enumerate"></a>enumerate</code></em> ()</p></td>
<td class="struct_member_description"><p>Creates a <a class="link" href="GSocketAddressEnumerator.html" title="GSocketAddressEnumerator"><span class="type">GSocketAddressEnumerator</span></a></p></td>
<td class="struct_member_annotations"> </td>
</tr>
<tr>
<td class="struct_member_name"><p><em class="structfield"><code><a name="GSocketConnectableIface.proxy-enumerate"></a>proxy_enumerate</code></em> ()</p></td>
<td class="struct_member_description"><p>Creates a <a class="link" href="GProxyAddressEnumerator.html" title="GProxyAddressEnumerator"><span class="type">GProxyAddressEnumerator</span></a></p></td>
<td class="struct_member_annotations"> </td>
</tr>
<tr>
<td class="struct_member_name"><p><em class="structfield"><code><a name="GSocketConnectableIface.to-string"></a>to_string</code></em> ()</p></td>
<td class="struct_member_description"><p>Format the connectable’s address as a string for debugging.
Implementing this is optional. (Since: 2.48)</p></td>
<td class="struct_member_annotations"> </td>
</tr>
</tbody>
</table></div>
</div>
</div>
</div>
</div>
<div class="footer">
<hr>Generated by GTK-Doc V1.26.1</div>
</body>
</html>